Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stake percentage + operator address to ejection reporting (dataapi + cli) #815

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

pschork
Copy link
Contributor

@pschork pschork commented Oct 16, 2024

Dataapi + cli tool to generate ejections reports
Outputs 3 tables

  1. By OperatorId
  2. By Ejection txn
  3. Aggregate stake % per quorum per transaction
./bin/ejections --days 1
┌───┬────────────────────────────────────────────┬────────┬────────────────────┬───────────────────────────┬────────────────────────────────────────────────────────────────────┐
│   │ OPERATOR ADDRESS                           │ QUORUM │            STAKE % │ TIMESTAMP                 │ TXN                                                                │
├───┼────────────────────────────────────────────┼────────┼────────────────────┼───────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ 1 │ 0x44220295991e4fe4f3a4c5fe04e96b1b19960766 │    0   │ 0.2804360720911991 │ 2024-10-24T15:09:12-07:00 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │
├───┼────────────────────────────────────────────┼────────┼────────────────────┼───────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ 2 │ 0x37b7f290ced6aa5ae9b92da34b50079ce4bb96de │    0   │ 0.5179906113512727 │ 2024-10-24T15:09:12-07:00 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │
├───┼────────────────────────────────────────────┼────────┼────────────────────┼───────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ 3 │ 0x44220295991e4fe4f3a4c5fe04e96b1b19960766 │    1   │ 0.6714456596104785 │ 2024-10-24T15:09:12-07:00 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │
├───┼────────────────────────────────────────────┼────────┼────────────────────┼───────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ 4 │ 0x304ddbd6ad3162b7cd901356608a8c0d56b55421 │    1   │ 3.0643512311364463 │ 2024-10-24T15:09:12-07:00 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │
├───┼────────────────────────────────────────────┼────────┼────────────────────┼───────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ 5 │ 0xce637eac04570dbb24582383e4c64757b0b59a1f │    1   │ 17.325436463002877 │ 2024-10-24T15:09:12-07:00 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │
└───┴────────────────────────────────────────────┴────────┴────────────────────┴───────────────────────────┴────────────────────────────────────────────────────────────────────┘
┌───┬────────────────────────────────────────────────────────────────────┬───────────────────────────┬────────────────────────────────────────────┬────────┬────────────────────┐
│   │ TXN                                                                │ TIMESTAMP                 │ OPERATOR ADDRESS                           │ QUORUM │            STAKE % │
├───┼────────────────────────────────────────────────────────────────────┼───────────────────────────┼────────────────────────────────────────────┼────────┼────────────────────┤
│ 1 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │ 2024-10-24T15:09:12-07:00 │ 0x44220295991e4fe4f3a4c5fe04e96b1b19960766 │    0   │ 0.2804360720911991 │
├───┤                                                                    │                           ├────────────────────────────────────────────┼────────┼────────────────────┤
│ 2 │                                                                    │                           │ 0x37b7f290ced6aa5ae9b92da34b50079ce4bb96de │    0   │ 0.5179906113512727 │
├───┤                                                                    │                           ├────────────────────────────────────────────┼────────┼────────────────────┤
│ 3 │                                                                    │                           │ 0x44220295991e4fe4f3a4c5fe04e96b1b19960766 │    1   │ 0.6714456596104785 │
├───┤                                                                    │                           ├────────────────────────────────────────────┼────────┼────────────────────┤
│ 4 │                                                                    │                           │ 0x304ddbd6ad3162b7cd901356608a8c0d56b55421 │    1   │ 3.0643512311364463 │
├───┤                                                                    │                           ├────────────────────────────────────────────┼────────┼────────────────────┤
│ 5 │                                                                    │                           │ 0xce637eac04570dbb24582383e4c64757b0b59a1f │    1   │ 17.325436463002877 │
└───┴────────────────────────────────────────────────────────────────────┴───────────────────────────┴────────────────────────────────────────────┴────────┴────────────────────┘
┌───┬────────────────────────────────────────────────────────────────────┬───────────────────────────┬────────┬────────────────────┬───────────┐
│   │ TXN                                                                │ TIMESTAMP                 │ QUORUM │            STAKE % │ OPERATORS │
├───┼────────────────────────────────────────────────────────────────────┼───────────────────────────┼────────┼────────────────────┼───────────┤
│ 1 │ 0x5666f05ddc8f3901db0898a636fb0026045b6d54a11b500852b82580ae804251 │ 2024-10-24T15:09:12-07:00 │    0   │ 0.7984266834424718 │     2     │
├───┤                                                                    │                           ├────────┼────────────────────┼───────────┤
│ 2 │                                                                    │                           │    1   │ 21.061233353749802 │     3     │
└───┴────────────────────────────────────────────────────────────────────┴───────────────────────────┴────────┴────────────────────┴───────────┘

@pschork pschork requested review from bxue-l2 and jianoaix October 17, 2024 00:03
@pschork pschork force-pushed the pschork/ejections_cli branch 2 times, most recently from 70808f0 to 3d4cfdd Compare October 17, 2024 00:56
@pschork pschork force-pushed the pschork/ejections_cli branch from 776b519 to d2bb6f3 Compare October 24, 2024 07:55
@pschork
Copy link
Contributor Author

pschork commented Oct 25, 2024

Ejections DataAPI response

{
  "ejections": [
    {
      "operator_id": "0xf512db9a07eefc22336c0de9f0dd8cb71400d0718e9ed00cb4af2643dc64325e",
      "operator_address": "0x08300f3797dcee9cc813ebaae25127b4e3b550e3",
      "quorum": 1,
      "block_number": 2126464,
      "block_timestamp": "2024-08-13T18:47:12Z",
      "transaction_hash": "0x23ba5240a21cb7e56a8deb971833d188ff5e30562bed5fb70e44b2a624809367",
      "stake_percentage": 9.66183574879227
    },
    {
      "operator_id": "0x45fc52054b0b4b95f9188959eac542abf08537b62575fb0c89a8e42a77a93497",
      "operator_address": "0xcb14cfaac122e52024232583e7354589aede74ff",
      "quorum": 1,
      "block_number": 2290044,
      "block_timestamp": "2024-09-07T18:47:12Z",
      "transaction_hash": "0x72044cb9bd5a05c5de466d698ffeff475d2e2e2df104e73b67bfac72bcc7814a",
      "stake_percentage": 13.043478260869565
    }

Adds second table ordered by ejection txn

Sort results in descending order

Consolidate table logic

Add stake percentage calculation to ejection report

Add stake percentage to operator ejections data api

Update swagger

Fix id->address mapping

Lint
@pschork pschork force-pushed the pschork/ejections_cli branch from 498bd74 to 3fc378b Compare October 25, 2024 01:03
@pschork pschork changed the title Ejections report cli Add stake percentage + operator address to ejection reporting (dataapi + cli) Oct 25, 2024
@pschork pschork force-pushed the pschork/ejections_cli branch from 44c12d4 to 6fb398a Compare October 25, 2024 07:31
for _, ejection := range operatorEjections {
previouseBlock := ejection.BlockNumber - 1
if _, exists := stateCache[previouseBlock]; !exists {
state, err := s.chainState.GetOperatorState(context.Background(), uint(previouseBlock), []uint8{0, 1})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would be a good way to pass in/out the quorum information in the report. Not something immediately clear to me what the best option would be. Not even sure if we eject quorum2 at all. I don't think we need to address it here. But put a note somewhere would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to construct an ordered slice of the set of quorums.

subgraphApi := subgraph.NewApi(config.SubgraphEndpoint, config.SubgraphEndpoint)
subgraphClient := dataapi.NewSubgraphClient(subgraphApi, logger)

ejections, err := subgraphClient.QueryOperatorEjectionsForTimeWindow(context.Background(), int32(config.Days), config.OperatorId, config.First, config.Skip)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this section of code is highly similar to the codeblock above. Create a new function?

@pschork pschork force-pushed the pschork/ejections_cli branch from bc1c491 to 6cf0f91 Compare October 25, 2024 17:45
@pschork pschork merged commit 0ec3d07 into master Oct 28, 2024
9 checks passed
ian-shim pushed a commit to ian-shim/eigenda that referenced this pull request Oct 29, 2024
@pschork pschork deleted the pschork/ejections_cli branch November 5, 2024 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants